\(\int \frac {\cot ^2(c+d x)}{(a+a \sin (c+d x))^2} \, dx\) [312]

   Optimal result
   Rubi [A] (verified)
   Mathematica [B] (verified)
   Maple [A] (verified)
   Fricas [B] (verification not implemented)
   Sympy [F]
   Maxima [B] (verification not implemented)
   Giac [A] (verification not implemented)
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 21, antiderivative size = 54 \[ \int \frac {\cot ^2(c+d x)}{(a+a \sin (c+d x))^2} \, dx=\frac {2 \text {arctanh}(\cos (c+d x))}{a^2 d}-\frac {\cot (c+d x)}{a^2 d}-\frac {2 \cot (c+d x)}{a^2 d (1+\csc (c+d x))} \]

[Out]

2*arctanh(cos(d*x+c))/a^2/d-3*cot(d*x+c)/a^2/d+2*cot(d*x+c)/a^2/d/(1+sin(d*x+c))

Rubi [A] (verified)

Time = 0.07 (sec) , antiderivative size = 54, normalized size of antiderivative = 1.00, number of steps used = 7, number of rules used = 5, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.238, Rules used = {2788, 3855, 3852, 8, 3862} \[ \int \frac {\cot ^2(c+d x)}{(a+a \sin (c+d x))^2} \, dx=\frac {2 \text {arctanh}(\cos (c+d x))}{a^2 d}-\frac {\cot (c+d x)}{a^2 d}-\frac {2 \cot (c+d x)}{a^2 d (\csc (c+d x)+1)} \]

[In]

Int[Cot[c + d*x]^2/(a + a*Sin[c + d*x])^2,x]

[Out]

(2*ArcTanh[Cos[c + d*x]])/(a^2*d) - Cot[c + d*x]/(a^2*d) - (2*Cot[c + d*x])/(a^2*d*(1 + Csc[c + d*x]))

Rule 8

Int[a_, x_Symbol] :> Simp[a*x, x] /; FreeQ[a, x]

Rule 2788

Int[((a_) + (b_.)*sin[(e_.) + (f_.)*(x_)])^(m_)*tan[(e_.) + (f_.)*(x_)]^(p_), x_Symbol] :> Dist[a^p, Int[Expan
dIntegrand[Sin[e + f*x]^p*((a + b*Sin[e + f*x])^(m - p/2)/(a - b*Sin[e + f*x])^(p/2)), x], x], x] /; FreeQ[{a,
 b, e, f}, x] && EqQ[a^2 - b^2, 0] && IntegersQ[m, p/2] && (LtQ[p, 0] || GtQ[m - p/2, 0])

Rule 3852

Int[csc[(c_.) + (d_.)*(x_)]^(n_), x_Symbol] :> Dist[-d^(-1), Subst[Int[ExpandIntegrand[(1 + x^2)^(n/2 - 1), x]
, x], x, Cot[c + d*x]], x] /; FreeQ[{c, d}, x] && IGtQ[n/2, 0]

Rule 3855

Int[csc[(c_.) + (d_.)*(x_)], x_Symbol] :> Simp[-ArcTanh[Cos[c + d*x]]/d, x] /; FreeQ[{c, d}, x]

Rule 3862

Int[(csc[(c_.) + (d_.)*(x_)]*(b_.) + (a_))^(n_), x_Symbol] :> Simp[(-Cot[c + d*x])*((a + b*Csc[c + d*x])^n/(d*
(2*n + 1))), x] + Dist[1/(a^2*(2*n + 1)), Int[(a + b*Csc[c + d*x])^(n + 1)*(a*(2*n + 1) - b*(n + 1)*Csc[c + d*
x]), x], x] /; FreeQ[{a, b, c, d}, x] && EqQ[a^2 - b^2, 0] && LeQ[n, -1] && IntegerQ[2*n]

Rubi steps \begin{align*} \text {integral}& = \frac {\int \left (2-2 \csc (c+d x)+\csc ^2(c+d x)-\frac {2}{1+\csc (c+d x)}\right ) \, dx}{a^2} \\ & = \frac {2 x}{a^2}+\frac {\int \csc ^2(c+d x) \, dx}{a^2}-\frac {2 \int \csc (c+d x) \, dx}{a^2}-\frac {2 \int \frac {1}{1+\csc (c+d x)} \, dx}{a^2} \\ & = \frac {2 x}{a^2}+\frac {2 \text {arctanh}(\cos (c+d x))}{a^2 d}-\frac {2 \cot (c+d x)}{a^2 d (1+\csc (c+d x))}+\frac {2 \int -1 \, dx}{a^2}-\frac {\text {Subst}(\int 1 \, dx,x,\cot (c+d x))}{a^2 d} \\ & = \frac {2 \text {arctanh}(\cos (c+d x))}{a^2 d}-\frac {\cot (c+d x)}{a^2 d}-\frac {2 \cot (c+d x)}{a^2 d (1+\csc (c+d x))} \\ \end{align*}

Mathematica [B] (verified)

Leaf count is larger than twice the leaf count of optimal. \(216\) vs. \(2(54)=108\).

Time = 0.94 (sec) , antiderivative size = 216, normalized size of antiderivative = 4.00 \[ \int \frac {\cot ^2(c+d x)}{(a+a \sin (c+d x))^2} \, dx=-\frac {\csc \left (\frac {1}{2} (c+d x)\right ) \sec \left (\frac {1}{2} (c+d x)\right ) \left (\cos \left (\frac {1}{2} (c+d x)\right )+\sin \left (\frac {1}{2} (c+d x)\right )\right )^3 \left (\cos \left (\frac {3}{2} (c+d x)\right ) \left (5+2 \log \left (\cos \left (\frac {1}{2} (c+d x)\right )\right )-2 \log \left (\sin \left (\frac {1}{2} (c+d x)\right )\right )\right )+\cos \left (\frac {1}{2} (c+d x)\right ) \left (-3-2 \log \left (\cos \left (\frac {1}{2} (c+d x)\right )\right )+2 \log \left (\sin \left (\frac {1}{2} (c+d x)\right )\right )\right )+2 \left (-2 \log \left (\cos \left (\frac {1}{2} (c+d x)\right )\right )+2 \log \left (\sin \left (\frac {1}{2} (c+d x)\right )\right )+\cos (c+d x) \left (1-2 \log \left (\cos \left (\frac {1}{2} (c+d x)\right )\right )+2 \log \left (\sin \left (\frac {1}{2} (c+d x)\right )\right )\right )\right ) \sin \left (\frac {1}{2} (c+d x)\right )\right )}{4 a^2 d (1+\sin (c+d x))^2} \]

[In]

Integrate[Cot[c + d*x]^2/(a + a*Sin[c + d*x])^2,x]

[Out]

-1/4*(Csc[(c + d*x)/2]*Sec[(c + d*x)/2]*(Cos[(c + d*x)/2] + Sin[(c + d*x)/2])^3*(Cos[(3*(c + d*x))/2]*(5 + 2*L
og[Cos[(c + d*x)/2]] - 2*Log[Sin[(c + d*x)/2]]) + Cos[(c + d*x)/2]*(-3 - 2*Log[Cos[(c + d*x)/2]] + 2*Log[Sin[(
c + d*x)/2]]) + 2*(-2*Log[Cos[(c + d*x)/2]] + 2*Log[Sin[(c + d*x)/2]] + Cos[c + d*x]*(1 - 2*Log[Cos[(c + d*x)/
2]] + 2*Log[Sin[(c + d*x)/2]]))*Sin[(c + d*x)/2]))/(a^2*d*(1 + Sin[c + d*x])^2)

Maple [A] (verified)

Time = 0.32 (sec) , antiderivative size = 59, normalized size of antiderivative = 1.09

method result size
derivativedivides \(\frac {\tan \left (\frac {d x}{2}+\frac {c}{2}\right )-\frac {1}{\tan \left (\frac {d x}{2}+\frac {c}{2}\right )}-4 \ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )\right )-\frac {8}{\tan \left (\frac {d x}{2}+\frac {c}{2}\right )+1}}{2 d \,a^{2}}\) \(59\)
default \(\frac {\tan \left (\frac {d x}{2}+\frac {c}{2}\right )-\frac {1}{\tan \left (\frac {d x}{2}+\frac {c}{2}\right )}-4 \ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )\right )-\frac {8}{\tan \left (\frac {d x}{2}+\frac {c}{2}\right )+1}}{2 d \,a^{2}}\) \(59\)
parallelrisch \(\frac {\left (-4 \tan \left (\frac {d x}{2}+\frac {c}{2}\right )-4\right ) \ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )\right )+\tan ^{2}\left (\frac {d x}{2}+\frac {c}{2}\right )-\cot \left (\frac {d x}{2}+\frac {c}{2}\right )+10 \tan \left (\frac {d x}{2}+\frac {c}{2}\right )}{2 d \,a^{2} \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )+1\right )}\) \(80\)
risch \(-\frac {2 \left (-3+i {\mathrm e}^{i \left (d x +c \right )}+2 \,{\mathrm e}^{2 i \left (d x +c \right )}\right )}{\left ({\mathrm e}^{2 i \left (d x +c \right )}-1\right ) \left ({\mathrm e}^{i \left (d x +c \right )}+i\right ) d \,a^{2}}+\frac {2 \ln \left ({\mathrm e}^{i \left (d x +c \right )}+1\right )}{d \,a^{2}}-\frac {2 \ln \left ({\mathrm e}^{i \left (d x +c \right )}-1\right )}{d \,a^{2}}\) \(102\)
norman \(\frac {-\frac {7 \tan \left (\frac {d x}{2}+\frac {c}{2}\right )}{d a}-\frac {1}{2 a d}+\frac {\tan ^{5}\left (\frac {d x}{2}+\frac {c}{2}\right )}{2 d a}-\frac {27 \left (\tan ^{2}\left (\frac {d x}{2}+\frac {c}{2}\right )\right )}{2 d a}-\frac {15 \left (\tan ^{3}\left (\frac {d x}{2}+\frac {c}{2}\right )\right )}{2 d a}}{a \tan \left (\frac {d x}{2}+\frac {c}{2}\right ) \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )+1\right )^{3}}-\frac {2 \ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )\right )}{d \,a^{2}}\) \(131\)

[In]

int(cos(d*x+c)^2*csc(d*x+c)^2/(a+a*sin(d*x+c))^2,x,method=_RETURNVERBOSE)

[Out]

1/2/d/a^2*(tan(1/2*d*x+1/2*c)-1/tan(1/2*d*x+1/2*c)-4*ln(tan(1/2*d*x+1/2*c))-8/(tan(1/2*d*x+1/2*c)+1))

Fricas [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 160 vs. \(2 (54) = 108\).

Time = 0.30 (sec) , antiderivative size = 160, normalized size of antiderivative = 2.96 \[ \int \frac {\cot ^2(c+d x)}{(a+a \sin (c+d x))^2} \, dx=\frac {3 \, \cos \left (d x + c\right )^{2} + {\left (\cos \left (d x + c\right )^{2} - {\left (\cos \left (d x + c\right ) + 1\right )} \sin \left (d x + c\right ) - 1\right )} \log \left (\frac {1}{2} \, \cos \left (d x + c\right ) + \frac {1}{2}\right ) - {\left (\cos \left (d x + c\right )^{2} - {\left (\cos \left (d x + c\right ) + 1\right )} \sin \left (d x + c\right ) - 1\right )} \log \left (-\frac {1}{2} \, \cos \left (d x + c\right ) + \frac {1}{2}\right ) + {\left (3 \, \cos \left (d x + c\right ) + 2\right )} \sin \left (d x + c\right ) + \cos \left (d x + c\right ) - 2}{a^{2} d \cos \left (d x + c\right )^{2} - a^{2} d - {\left (a^{2} d \cos \left (d x + c\right ) + a^{2} d\right )} \sin \left (d x + c\right )} \]

[In]

integrate(cos(d*x+c)^2*csc(d*x+c)^2/(a+a*sin(d*x+c))^2,x, algorithm="fricas")

[Out]

(3*cos(d*x + c)^2 + (cos(d*x + c)^2 - (cos(d*x + c) + 1)*sin(d*x + c) - 1)*log(1/2*cos(d*x + c) + 1/2) - (cos(
d*x + c)^2 - (cos(d*x + c) + 1)*sin(d*x + c) - 1)*log(-1/2*cos(d*x + c) + 1/2) + (3*cos(d*x + c) + 2)*sin(d*x
+ c) + cos(d*x + c) - 2)/(a^2*d*cos(d*x + c)^2 - a^2*d - (a^2*d*cos(d*x + c) + a^2*d)*sin(d*x + c))

Sympy [F]

\[ \int \frac {\cot ^2(c+d x)}{(a+a \sin (c+d x))^2} \, dx=\frac {\int \frac {\cos ^{2}{\left (c + d x \right )} \csc ^{2}{\left (c + d x \right )}}{\sin ^{2}{\left (c + d x \right )} + 2 \sin {\left (c + d x \right )} + 1}\, dx}{a^{2}} \]

[In]

integrate(cos(d*x+c)**2*csc(d*x+c)**2/(a+a*sin(d*x+c))**2,x)

[Out]

Integral(cos(c + d*x)**2*csc(c + d*x)**2/(sin(c + d*x)**2 + 2*sin(c + d*x) + 1), x)/a**2

Maxima [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 116 vs. \(2 (54) = 108\).

Time = 0.21 (sec) , antiderivative size = 116, normalized size of antiderivative = 2.15 \[ \int \frac {\cot ^2(c+d x)}{(a+a \sin (c+d x))^2} \, dx=-\frac {\frac {\frac {9 \, \sin \left (d x + c\right )}{\cos \left (d x + c\right ) + 1} + 1}{\frac {a^{2} \sin \left (d x + c\right )}{\cos \left (d x + c\right ) + 1} + \frac {a^{2} \sin \left (d x + c\right )^{2}}{{\left (\cos \left (d x + c\right ) + 1\right )}^{2}}} + \frac {4 \, \log \left (\frac {\sin \left (d x + c\right )}{\cos \left (d x + c\right ) + 1}\right )}{a^{2}} - \frac {\sin \left (d x + c\right )}{a^{2} {\left (\cos \left (d x + c\right ) + 1\right )}}}{2 \, d} \]

[In]

integrate(cos(d*x+c)^2*csc(d*x+c)^2/(a+a*sin(d*x+c))^2,x, algorithm="maxima")

[Out]

-1/2*((9*sin(d*x + c)/(cos(d*x + c) + 1) + 1)/(a^2*sin(d*x + c)/(cos(d*x + c) + 1) + a^2*sin(d*x + c)^2/(cos(d
*x + c) + 1)^2) + 4*log(sin(d*x + c)/(cos(d*x + c) + 1))/a^2 - sin(d*x + c)/(a^2*(cos(d*x + c) + 1)))/d

Giac [A] (verification not implemented)

none

Time = 0.32 (sec) , antiderivative size = 90, normalized size of antiderivative = 1.67 \[ \int \frac {\cot ^2(c+d x)}{(a+a \sin (c+d x))^2} \, dx=-\frac {\frac {4 \, \log \left ({\left | \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) \right |}\right )}{a^{2}} - \frac {\tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )}{a^{2}} - \frac {2 \, \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{2} - 7 \, \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) - 1}{{\left (\tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{2} + \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )\right )} a^{2}}}{2 \, d} \]

[In]

integrate(cos(d*x+c)^2*csc(d*x+c)^2/(a+a*sin(d*x+c))^2,x, algorithm="giac")

[Out]

-1/2*(4*log(abs(tan(1/2*d*x + 1/2*c)))/a^2 - tan(1/2*d*x + 1/2*c)/a^2 - (2*tan(1/2*d*x + 1/2*c)^2 - 7*tan(1/2*
d*x + 1/2*c) - 1)/((tan(1/2*d*x + 1/2*c)^2 + tan(1/2*d*x + 1/2*c))*a^2))/d

Mupad [B] (verification not implemented)

Time = 9.45 (sec) , antiderivative size = 87, normalized size of antiderivative = 1.61 \[ \int \frac {\cot ^2(c+d x)}{(a+a \sin (c+d x))^2} \, dx=\frac {\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}{2\,a^2\,d}-\frac {9\,\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )+1}{d\,\left (2\,a^2\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^2+2\,a^2\,\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )\right )}-\frac {2\,\ln \left (\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )\right )}{a^2\,d} \]

[In]

int(cos(c + d*x)^2/(sin(c + d*x)^2*(a + a*sin(c + d*x))^2),x)

[Out]

tan(c/2 + (d*x)/2)/(2*a^2*d) - (9*tan(c/2 + (d*x)/2) + 1)/(d*(2*a^2*tan(c/2 + (d*x)/2)^2 + 2*a^2*tan(c/2 + (d*
x)/2))) - (2*log(tan(c/2 + (d*x)/2)))/(a^2*d)